package com.lujieni.aviator.config;

import com.googlecode.aviator.AviatorEvaluator;
import com.lujieni.aviator.demos.BetweenFunction;
import com.lujieni.aviator.demos.InFunc;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

/**
 * Aviator自定义函数配置类
 * 用于注册自定义函数到Aviator引擎
 */
@Configuration
public class AviatorFunctionConfig {

    /**
     * 在Spring容器初始化后注册自定义函数
     */
    @PostConstruct
    public void registerCustomFunctions123() {
        // 注册IN函数
        AviatorEvaluator.addFunction(new InFunc());
        
        // 注册BETWEEN函数
        AviatorEvaluator.addFunction(new BetweenFunction());
        
        System.out.println("Aviator自定义函数注册完成:");
        System.out.println("- in(value, item1, item2, ...) : 检查value是否在后续参数列表中");
        System.out.println("- between(value, min, max) : 检查value是否在min和max之间");
    }
}
